package com.h2cloud;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: wulongkai
 * @create: 2022-11-08 15:08
 **/
public class en {
    public static void main(String[] args) {
//        Gson gson = new Gson();
//        Persons p = new Persons("longkai");
////        p.setName("longkai");
//        String s = gson.toJson(p);
//        System.out.println("fromJson");
//        Persons persons = gson.fromJson(s, Persons.class);
//        System.out.println(persons);

        students s2 = new students("s2");
        s2.add2List();
        zhiyuan z2 = new zhiyuan("z2");
        z2.add2List();

        System.out.println("s2.getChildList() = " + s2.getChildList());
        System.out.println("z2.getChildList() = " + z2.getChildList());
    }
}

@Data
@Getter
@Setter
class Persons {

    String name;

    List<String> childList;

    public Persons() {
    }

    public Persons(String name) {
        this.name = name;
        childList = new ArrayList<>();
        System.out.println("init");
    }

    public void add2List() {
        childList.add(this.name);
    }
}

@Data
@Getter
@Setter
class students extends Persons {
    public students(String name) {
        super(name);
    }
}

@Data
@Getter
@Setter
class zhiyuan extends Persons {
    public zhiyuan(String name) {
        super(name);
    }
}


